package com.hedgehoglab.fixxclipse.treeviewer.ui;


import org.eclipse.jface.viewers.LabelProvider;

import com.hedgehoglab.fixxclipse.treeviewer.model.Fixx;
import com.hedgehoglab.fixxclipse.treeviewer.model.Issue;
import com.hedgehoglab.fixxclipse.treeviewer.model.Project;
import com.hedgehoglab.fixxclipse.treeviewer.model.Version;


public class FixxLabelProvider extends LabelProvider {

	public String getText(Object element) {
		if (element instanceof Fixx) {
			if(((Fixx)element).getName() == null) {
				return "fixx";
			} else {
				return ((Fixx)element).getName();
			}
		} else if (element instanceof Project) {
			return ((Project)element).getName();
		}
		else if (element instanceof Version) {
			return ((Version)element).getName();
		}
		else if (element instanceof Issue) {
			return ((Issue)element).getTitle();
		}else {
			throw unknownElement(element);
		}
	}
	
	protected RuntimeException unknownElement(Object element) {
		return new RuntimeException("Unknown type of element in tree of type " + element.getClass().getName());
	}
}
